# Author    :Dun_Hz
# Time      :2025-04-07 10:55

def max_seat_rate(m, n, records):
  res = []
  backtracking(records, 0, [], res)
  max_usage=0
  for assignment in res:
    if isValid(assignment,m, n):
      ans=cal_usage(assignment)
      max_usage = max(max_usage, ans)
  return max_usage

# 回溯 所有组合
def backtracking(records, startIndex, path, res):
  res.append(path[:])

  for i in range(startIndex, len(records)):
    path.append(records[startIndex])
    backtracking(records, startIndex+1, path, res)
    path.pop()

def isValid(assignment, m, n):
  seat=[0]*n
  for start, end in assignment:
    for i in range(start, end):
      seat[i]+=1
      if seat[i]>m:
        return False
  return True

def cal_usage(assigment):
  return sum(end-start for start, end in assigment)


m, n, x=map(int, input().split(' '))
records=[]
for _ in range(x):
  start, end= map(int, input().split(" "))
  records.append((start, end))

print(max_seat_rate(m,n,records))
